import React, { Component } from "react";
import { Provider } from "../../../utils/myContext";
import Son from "./Son"

export default class index extends Component {
  
  constructor(props){
    super(props);
    this.state={
      count:8
    }
  }

  changeCount=()=>{
    this.setState({
      count:this.state.count+1
    })
  }

  render() {
    return (
      <Provider value={this.state.count}>
        <div>
          <h1>状态树传参（跨级）</h1>
          <h3>父组件</h3>
          <p>count：{this.state.count}</p>
          <input type="button" value="修改count" onClick={this.changeCount} />
          <Son></Son>
        </div>
      </Provider>
    );
  }
}
